package org.budo.activiti.form.type;

import org.activiti.engine.form.AbstractFormType;
import org.apache.commons.lang3.StringUtils;
import org.budo.time.Time;

/**
 * @author lmw
 */
public class MonthFormType extends AbstractFormType {
    private static final long serialVersionUID = 7036204315982673458L;

    private static final String NAME = "month";

    @Override
    public String getName() {
        return NAME;
    }

    @Override
    public Object convertFormValueToModelValue(String propertyValue) {
        if (StringUtils.isEmpty(propertyValue)) {
            return null;
        }

        return Time.when(propertyValue).plusHour(TimeFormType.TIME_ZONE).toDate();
    }

    @Override
    public String convertModelValueToFormValue(Object modelValue) {
        throw new RuntimeException();
    }
}